package cur.nature.admin.dao;

import cur.nature.admin.common.config.DBAdminConfig;
import cur.nature.admin.model.po.Admin_LogPO;
import cur.nature.admin.model.vo.Admin_LogVO;
import cur.nature.framework.mvc.crud.CrudDao;
import cur.nature.tinyorm.core.bean.PageBean;

import cur.nature.tinyorm.core.template.DefaultJdbcTemplate;
import cur.nature.framework.core.util.StringUtil;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

/**
 * 通用字典 Dao
 * 作者：Auto Generator By wujian
 * 生成日期：2023-07-16 14:17:26
 */
@Component
@DependsOn(DefaultJdbcTemplate.TEMPLATE)
public class Admin_LogDao extends CrudDao<Admin_LogPO, Admin_LogVO> {
    public Admin_LogDao(@Qualifier(DBAdminConfig.TEMPLATE) DefaultJdbcTemplate template) {
        super(Admin_LogPO.class, Admin_LogVO.class, template);
    }

    public PageBean<Admin_LogVO> list(Admin_LogVO.list_Param param) throws Exception {
        StringBuilder condition = new StringBuilder(" 1=1 ");
        if(StringUtil.isNotEmpty(param.getKeyword())){
            condition.append(" and a.code like '"+param.getKeyword()+"%'");
        }
        String sql = "select a.code,a.remark,a.ip,b.name operator,a.param,a.result,a.spent_time,a.id,a.create_user,a.create_date " +
                "from admin_sys_log a left join admin_sys_user b on a.operator=b.id " +
                "where  "+condition+"  order by create_date desc ";
        PageBean<Admin_LogVO> list = queryForPage(sql, param.buildPage(),
                null, Admin_LogVO.class);
        return list;
    }

}

